const teafeaModel = require('../models/teamfeatures.js')

class TeamfeatureCtrl {

    async list() {
        let lst = await teafeaModel.find();//.sort('id');
        return lst.map(m=>m.toJSON());
    }

    async create(teafeaData) {
        let teafea = new teafeaModel(teafeaData);
        teafea = await teafea.save();
        return teafea.toJSON();
    }

    async retrieve(id) {
        let teafea = await teafeaModel.findById(id);
        return teafea?teafea.toJSON(): null;
    }

    async upsert(id, teafeaData) {
        teafeaData.id = id;
        let teafea = await teafeaModell.upsert(id, teafeaData);
        return teafea.toJSON();
    }
    async removeById(id) {
        await teafeaModel.removeById(id);
        return 1;
    }
    async find(filter)
    {
        let r = await teafeaModel.find(filter);
        return r.map(e=>e.toJSON());
    }
}
module.exports = new TeamfeatureCtrl();